#include "AxeBullet.h"

AxeBullet::AxeBullet()
{
    static SDL_Texture *tex = ResourcesManager::Instance().texturePool[ResID::Tex_BulletAxe];
    static const std::vector<int> idx_list = {0, 1, 2, 3, 4, 5, 6, 7, 8};
    animation.SetLoop(true);
    animation.SetInterval(0.1);
    animation.SetFrameData(tex, 4, 2, idx_list);
    size.x = 48, size.y = 48;
}

void AxeBullet::OnCollide(Enemy *enemy)
{
    static ResourcesManager::SoundPool &sound_pool = ResourcesManager::Instance().soundPool;
    switch (rand() % 3) {
        case 0:
            Mix_PlayChannel(-1, sound_pool[ResID::Sound_AxeHit_1], 0);
            break;
        case 1:
            Mix_PlayChannel(-1, sound_pool[ResID::Sound_AxeHit_2], 0);
            break;
        case 2:
            Mix_PlayChannel(-1, sound_pool[ResID::Sound_AxeHit_3], 0);
            break;
    }

    enemy->SlowDown();
    Bullet::OnCollide(enemy);
}
